/*全局变量*/
let rootUrl = '',
  apiUrl = '',
  myServiceUrl = '',
  crmApiUrl = '',
  biApiUrl = '',
  lesseeid = '13',
  token = '',
  user = {};

const initToken = () => {
  // 获取当前页面的URL
  const url = new URL(window.location.href);
  // 检查URL中是否包含token参数
  // token = url.searchParams.get('token');
  token = url.href.split('token=')[1];
  console.log(url.href.split('token=')[1],'token');
  if (token) {
    localStorage.setItem('develop_token', token)
  } else {
    token = localStorage.getItem('develop_token')
  }
}
if (process.env.NODE_ENV == 'development') {
  console.log('开发环境');
  rootUrl = 'http://wx.4006002222.com';
  apiUrl = '/hifapiostest';
  myServiceUrl = '/qytest';
  crmApiUrl = '/crmtestapi2/WxService?method=';
  biApiUrl = 'https://biapex.huanai.com';
  // apiUrl = "/hifapi";
  // myServiceUrl = "/qy";
  // crmApiUrl = "/crmapi2/WxService?method=";
  initToken();
  // token =
  //   'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImUxYjA5ODQ2LWM4Y2YtNGUyMy05YjU2LTNmMjQ3Y2Y3ZDg3NCJ9.FLgNQ7xIZqDeoSK8CnLhZE7xDzGbRTX23zK4p_Dh7tNKnJ1Sajcw5zZ9MGkMJDW6K34swmbnyNFhOsx40-_mpg';
  
  user = {
    id: 'HN030637',
    name: '苏文柔',
    position: '前端开发工程师',
    dept: '信息部技术开发部',
    rp02: '',
    rp03: '',
    brand: '',
    storeName: '',
    storeAddress: '',
    phone: '13249425230',
    avatar:
      'https://wework.qpic.cn/wwhead/duc2TvpEgSTPk74IwG7Bs1eenc6tmSFS3vphgia4d9M4H7xeu4cCtPF714ib7ukdsv2V24Wib6ffzE/0',
    external_userid: 'wmiQjXCQAAKyEv1JSBv3d5DcYiePv7IQ',
  };
} else {
  console.log('生产环境');
  rootUrl = location.origin;
  // apiUrl = '/hifapi';
  apiUrl = '/hifapiostest';
  myServiceUrl = '/qy';
  crmApiUrl = '/crmapi/WxService?method=';
  biApiUrl = 'https://biapex.huanai.com';
}

export default {
  api: rootUrl + apiUrl,
  serviceurl: rootUrl + myServiceUrl,
  crmApiUrl: rootUrl + crmApiUrl,
  biApiUrl: biApiUrl,
  lesseeid: lesseeid,
  token: token,
  user: user,
  appid: '',
};
